<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><{$site_title}>管理中心</title>
<script type="text/javascript">
//CharMode函数 
//测试某个字符是属于哪一类. 
function CharMode(iN){ 
if (iN>=48 && iN <=57) //数字 
return 1; 
if (iN>=65 && iN <=90) //大写字母 
return 2; 
if (iN>=97 && iN <=122) //小写 
return 4; 
else 
return 8; //特殊字符 
} 
//bitTotal函数 
//计算出当前密码当中一共有多少种模式 
function bitTotal(num){ 
modes=0; 
for (i=0;i<4;i++){ 
if (num & 1) modes++; 
num>>>=1; 
} 
return modes; 
} 
//checkStrong函数 
//返回密码的强度级别 
function checkStrong(sPW){ 
if (sPW.length<=4) 
return 0; //密码太短 
Modes=0; 
for (i=0;i<sPW.length;i++){ 
//测试每一个字符的类别并统计一共有多少种模式. 
Modes|=CharMode(sPW.charCodeAt(i)); 
} 
return bitTotal(Modes); 
} 
//pwStrength函数 
//当用户放开键盘或密码输入框失去焦点时,根据不同的级别显示不同的颜色 
function pwStrength(pwd){ 
O_color="#eeeeee"; 
L_color="#ffa0a0"; 
M_color="#ff9b3a"; 
H_color="#a5e09b"; 
if (pwd==null||pwd==''){ 
Lcolor=Mcolor=Hcolor=O_color; 
} 
else{ 
S_level=checkStrong(pwd); 
switch(S_level) { 
case 0: 
Lcolor=Mcolor=Hcolor=O_color; 
case 1: 
Lcolor=L_color; 
Mcolor=Hcolor=O_color; 
break; 
case 2: 
Lcolor=Mcolor=M_color; 
Hcolor=O_color; 
break; 
default: 
Lcolor=Mcolor=Hcolor=H_color; 
} 
} 
document.getElementById("strength_L").style.background=Lcolor; 
document.getElementById("strength_M").style.background=Mcolor; 
document.getElementById("strength_H").style.background=Hcolor; 
return; 
} 
</script>
<link href="css/style.css" type="text/css" rel="stylesheet"/>
<style type="text/css">
<!--
.STYLE1 {color: #990000}
.STYLE2 {color: #009900}
.STYLE3 {color: #0066FF}
.input {float: left; margin-left: 10px;}
-->
</style>
<script src="js/jquery.js" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="css/validator.css"></link>
<script src="js/formValidator.js" type="text/javascript"></script>
<script src="js/formValidatorRegex.js" type="text/javascript"></script>
<script type="text/javascript">
	$(document).ready(
		function(){
			$.formValidator.initConfig({formID:"myForm",onError:function(msg){alert(msg);},onSuccess:function(){return true;}});
			$("#oldpwd").formValidator({})
		    .ajaxValidator({
			    type : "get",
				url : "xgmm.php?action=pwd",
				dataType : "json",
				success : function(data){	
		            if( data == "1" )
					{
		                return true;
					}
		            else
					{
		                return false;
					}
				},
				error: function(){alert("服务器没有返回数据，可能服务器忙，请重试");},
				onError : "密码不对，请重新输入",
				onWait : "正在对用户名进行合法性校验，请稍候..."
			});
			$("#pwd2").formValidator({forcevalID:true,triggerEvent:"change"}).inputValidator({min:1,empty:{leftEmpty:false,rightEmpty:false,emptyError:"重复密码两边不能有空符号"},onError:"重复密码不能为空,请确认"}).compareValidator({desID:"pwd1",operateor:"=",onError:"2次密码不一致,请确认"});
		}
	)
	
	function queding(){
		var r=confirm('是否保存设置？');
		if(r!=true){
			return false;
		}
	}
</script>
</head>

<body>
<div class="box">
<div style="background:url(images/mainbj.jpg) repeat-x; line-height:31px; height:31px;">
<table width="262" height="31" border="0" cellpadding="0" cellspacing="0">
<tr><td width="41" align="center">
<img src="images/biao1.jpg" /></td>
<td width="221"><strong>当前位置</strong>：后台首页 &gt; 修改密码</td>
</tr></table>
</div>

<form action="xgmm.php" method="post" id="myForm">
<table class="lefttab" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><div style="height:26px; text-align:left; line-height:26px; background:url(images/xbj1.jpg) repeat-x; border:1px solid #e9f5fa;font-weight:bold;">&nbsp;&nbsp;修改密码</div>
</td></tr>
<tr>
  <td align="right">原密码：</td>
<td align="left">&nbsp;<input name="oldpwd" id="oldpwd" class="input" type="password" /></td>
</tr>
<tr>
  <td align="right">新密码：</td>
<td align="left">&nbsp;<input type="password" name="pwd1" id="pwd1" class="input" onKeyUp="pwStrength(this.value)" onBlur="pwStrength(this.value)"/></td>
</tr>
<tr>
  <td align="right">密码强度：</td>
<td align="left">
<div width="217" style="border:1px solid #CCC;display:inline; background:#f8f8f8;line-height:20px;"> 
<div  style="float:left; background:#f8f8f8;border-right:1px solid #CCCCCC; text-align:center; width:80px;" id="strength_L"><span class="STYLE1">弱</span></div> 
<div  style="float:left; background:#f8f8f8;border-right:1px solid #CCCCCC;text-align:center;  width:80px;" id="strength_M"><span class="STYLE2">中</span></div> 
<div  style="float:left; background:#f8f8f8;text-align:center;  width:80px;" id="strength_H"><span class="STYLE3">强</span></div> 
</div> </td>
</tr>
<tr>
  <td align="right">确认新密码：</td>
<td align="left">&nbsp;<input type="password" name="pwd2" id="pwd2" class="input"/></td>
</tr>
<tr><td colspan="2" height="50px">
  <p>&nbsp;    </p>
  <p align="left" style="margin-left:50px;">
    <input type="submit" name="submit" value="修改" class="inp" onclick="return queding()"/>
    <input type="reset" name="reset" value="重置" class="inp"/>
  </p>
  <p>&nbsp;</p></td>
</tr>
</table>
</form>

</div>
</body>
</html>
